package com.mep.auth.controller;

import com.mep.auth.feign.IFeignSysDeptApi;
import com.mep.auth.model.SysDept;
import com.mep.auth.service.SysDeptService;
import com.mep.common.http.HttpResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * 机构控制器
 * @author lyl
 * @date Jan 13, 2019
 */

@Api(value="007-dept的controller",tags="007-dept的controller")
@RestController
@RequestMapping("dept")
public class SysDeptController implements IFeignSysDeptApi {

	@Autowired
	private SysDeptService sysDeptService;

	@Override
	@ApiOperation(value="01.保存dept",notes="问题点:保存dept")
	@ApiOperationSupport(order = 1, author = "lyl")
	@PostMapping(value="/save")
	public HttpResult save(@RequestBody SysDept record) {
		return HttpResult.ok(sysDeptService.save(record));
	}

	@Override
	@ApiOperation(value="02.删除dept",notes="问题点:删除dept")
	@ApiOperationSupport(order = 2, author = "lyl")
	@PostMapping(value="/delete")
	public HttpResult delete(@RequestBody List<SysDept> records) {
		return HttpResult.ok(sysDeptService.delete(records));
	}

	@Override
	@ApiOperation(value="03.查询dept树数据",notes="问题点:查询dept树数据")
	@ApiOperationSupport(order = 3, author = "lyl")
	@PostMapping(value="/findTree")
	public HttpResult findTree() {
		return HttpResult.ok(sysDeptService.findTree());
	}

}
